#!/usr/bin/python
# -*- coding: utf-8 -*-
import maya.cmds as mc
import LZ_realistBodySys_commands
reload(LZ_realistBodySys_commands)
import LZ_realistBodySys_init
reload(LZ_realistBodySys_init)
'''
-------------------------------------------------------------------------------------

'''

"""
        #=====================================================#
        #         Script Name: realistBodySys templeBuilder   #
        #         Author:   lizhi                             #
        #         start date: Oct 31, 2014                    #
        #         start Updated: Oct 31, 2014                 #
        #         Update/Change this file at:                 #
        #         company: http://www.originalforce.com/      #
        #         Email:294596787@qq.com                      #
        # Please do not alter any information above this line #
        #=====================================================#
        #
        #python                                               #
        #directions (for use):                                #
        #                                                     #
        #                                                     #
        #=====================================================#
        """   

class LZ_realistBodySys_templeBuilder(LZ_realistBodySys_commands.LZ_realistBodySys_commands , LZ_realistBodySys_init.LZ_realistBodySys_init):
    def __init__(self):
    
        LZ_realistBodySys_init.LZ_realistBodySys_init.__init__(self)
        
    
    def LZ_realistBodySys_createTemple(self):
        '''
        =========================================================
        ||                                                     ||
        ||脊椎部分 位置                                        ||
        ||the  location of spine                               ||
        ||                                                     ||
        =========================================================
        '''
        
        centerPoint_hip =  self.centerPoint_hip
        centerPoint_hipEnd =  self.centerPoint_hipEnd
        centerPoint_spine1 =  self.centerPoint_spine1
        centerPoint_spine2 =  self.centerPoint_spine2
        centerPoint_chest =  self.centerPoint_chest
        
        centerPoint_neck =  self.centerPoint_neck
        centerPoint_head =  self.centerPoint_head
        centerPoint_headEnd =  self.centerPoint_headEnd
        centerPoint_jaw =  self.centerPoint_jaw
        centerPoint_jawEnd =  self.centerPoint_jawEnd
        #centerPoint_jawEnd =  ['Rbs_jawEnd_Temple',(0,151.941,-7.207)]
        #===========================================================
        #-------------
        locator_hip = self.locator_hip
        locator_neck = self.locator_neck
        
        spineCurve = []
        spine_reverse_temple_grp = self.spine_reverse_temple_grp
        
        #LocationBone_tailbone = ['Rbs_tailbone_Temple',(0,99.171,-9.045)]
        spine_temple_allInfo = [centerPoint_hip,centerPoint_hipEnd,centerPoint_spine1,centerPoint_spine2,centerPoint_chest,centerPoint_neck,centerPoint_head,centerPoint_headEnd,centerPoint_jaw,centerPoint_jawEnd]
        for s_t_ai in spine_temple_allInfo:
            
        
            self.LZ_createJnt_byInfo( s_t_ai[0], s_t_ai[1],(0,0,0))
            reverseJnt = self.createReverseJnt(objname = s_t_ai[0] , stept = 1 )
            
            if mc.objExists(spine_reverse_temple_grp) == 0:
                mc.group(em=True,n = spine_reverse_temple_grp )
                
            else:
                pass
            mc.parent(reverseJnt , spine_reverse_temple_grp)
            
            
        curvePointObj = [(centerPoint_hip,centerPoint_hipEnd,'Hip_Temple_curve'),(centerPoint_hip,centerPoint_spine1,'spine01_Temple_curve'),(centerPoint_spine1,centerPoint_spine2,'spine02_Temple_curve'),(centerPoint_spine2 ,centerPoint_chest,'chest_Temple_curve')
                        ,(centerPoint_chest ,centerPoint_neck,'neck_Temple_curve'),(centerPoint_neck ,centerPoint_head,'head_Temple_curve'),(centerPoint_head ,centerPoint_headEnd,'headend_Temple_curve'),(centerPoint_head ,centerPoint_jaw,'jaw_Temple_curve'),(centerPoint_jaw,centerPoint_jawEnd,'jawend_Temple_curve')]
        for cpo in curvePointObj:
            
            self.createStraightLine(curvename =cpo[2] , LocationInfo = [cpo[0][1],cpo[1][1]])
            spineCurve.append( cpo[2]  ) 
            mc.skinCluster( cpo[0][0],cpo[1][0],cpo[2])
            
        
        #===========================================================
        ##---------------------  parent locator -------------------
        
        self.LZ_createLocator_byInfo(locatorName = locator_neck[0], translateInfo = locator_neck[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  locator_neck[0],Visscle = 3)
        #self.lockAttr( obj = locator_neck[0] ,attr =['tx','rz','sx','sy','sz','v'])
        mc.parent(centerPoint_neck[0],centerPoint_head[0],centerPoint_headEnd[0],centerPoint_jaw[0],centerPoint_jawEnd[0],locator_neck[0])
        
        self.LZ_createLocator_byInfo(locatorName = locator_hip[0], translateInfo = locator_hip[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  locator_hip[0],Visscle = 3)
        #self.lockAttr( obj = locator_hip[0] ,attr =['tx','rz','sx','sy','sz','v'])
        
        mc.parent(centerPoint_chest[0],centerPoint_hip[0],centerPoint_hipEnd[0],centerPoint_spine1[0],centerPoint_spine2[0],locator_neck[0],locator_hip[0])
        
        
        mc.group(spineCurve,locator_hip[0],n='spine_temple_grp')
        for sc in spineCurve:
            self.referenceCurve(sc)
            skincluster_curve = self.getSkinCluster(sc)
            self.conneReverseAttr( skincluster_curve,1)
        '''
        =========================================================
        ||                                                     ||
        ||胳膊 位置                                            ||
        ||the  location of arm                                 ||
        ||                                                     ||
        =========================================================
        '''
        
        L_centerPoint_shoulder =  self.L_centerPoint_shoulder
        L_centerPoint_clavicle =  self.L_centerPoint_clavicle
        L_centerPoint_arm =  self.L_centerPoint_arm
        L_centerPoint_foreArm =  self.L_centerPoint_foreArm
        L_centerPoint_hand =  self.L_centerPoint_hand
        
        #===========================================================
        #-------------
        locator_shoulder = self.locator_shoulder
        locator_arm = self.locator_arm
        
        L_arm_curveTemple = []
        R_arm_curveTemple = []
        
        L_arm_temple_allInfo = [L_centerPoint_shoulder,L_centerPoint_clavicle,L_centerPoint_arm,L_centerPoint_foreArm,L_centerPoint_hand]
        for la_t_ai in L_arm_temple_allInfo:
            
            
            self.LZ_createJnt_byInfo( la_t_ai[0], la_t_ai[1],(0,0,0))
            reverseJnt = self.createReverseJnt(objname = la_t_ai[0] , stept = 1 )
            
            if mc.objExists(spine_reverse_temple_grp) == 0:
                mc.group(em=True,n = spine_reverse_temple_grp )
                
            else:
                pass
            mc.parent(reverseJnt , spine_reverse_temple_grp)
            
            #=======================================================
            #---------  mirror -----------------------
            R_armName = la_t_ai[0].replace('L_','R_')
            R_arm_translate = (la_t_ai[1][0]*-1,la_t_ai[1][1],la_t_ai[1][2] )
            
            self.LZ_createJnt_byInfo( R_armName, R_arm_translate ,(0,0,0))
            
            
            reverseJnt = self.createReverseJnt(objname = R_armName , stept = 1 )
            
            if mc.objExists(spine_reverse_temple_grp) == 0:
                mc.group(em=True,n = spine_reverse_temple_grp )
                
            else:
                pass
            mc.parent(reverseJnt , spine_reverse_temple_grp)
            #----------------------------------------------------------
        L_arm_curvePointObj = [(L_centerPoint_shoulder,L_centerPoint_clavicle,'L_shouder_Temple_curve'),(L_centerPoint_clavicle,L_centerPoint_arm,'L_clavicle_Temple_curve'),(L_centerPoint_arm,L_centerPoint_foreArm,'L_arm_Temple_curve'),(L_centerPoint_foreArm ,L_centerPoint_hand,'L_foreArm_Temple_curve')]
        for la_cpo in L_arm_curvePointObj:
            
            self.createStraightLine(curvename =la_cpo[2] , LocationInfo = [la_cpo[0][1],la_cpo[1][1]])
            L_arm_curveTemple.append( la_cpo[2] )
            
            mc.skinCluster( la_cpo[0][0],la_cpo[1][0],la_cpo[2])
            #======================================================
            #---------  mirror -----------------------
            
            R_startPositin = (la_cpo[0][1][0]*-1,la_cpo[0][1][1],la_cpo[0][1][2])
            R_endPositin = (la_cpo[1][1][0]*-1,la_cpo[1][1][1],la_cpo[1][1][2])
            
            R_startObj =  str(la_cpo[0][0]).replace( 'L_', 'R_')
            R_endObj =  str(la_cpo[1][0]).replace( 'L_', 'R_')
            
            R_arm_curveName = str(la_cpo[2]).replace('L_','R_')
            
            self.createStraightLine(curvename =R_arm_curveName , LocationInfo = [R_startPositin,R_endPositin ])
            R_arm_curveTemple.append(R_arm_curveName)
            
            mc.skinCluster( R_startObj , R_endObj ,R_arm_curveName )
            #-------------------------------------------------------------
        
        #===========================================================
        ##---------------------  parent locator -------------------
        
        self.LZ_createLocator_byInfo(locatorName = locator_arm[0], translateInfo = locator_arm[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  locator_arm[0],Visscle = 3)
        #self.lockAttr( obj = locator_arm[0] ,attr =['sx','sy','sz','v'])
        mc.parent(L_centerPoint_arm[0],L_centerPoint_foreArm[0],L_centerPoint_hand[0],locator_arm[0])
        
        self.LZ_createLocator_byInfo(locatorName = locator_shoulder[0], translateInfo = locator_shoulder[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  locator_shoulder[0],Visscle = 3)
        #self.lockAttr( obj = locator_shoulder[0] ,attr =['sx','sy','sz','v'])
        mc.parent(L_centerPoint_shoulder[0],L_centerPoint_clavicle[0],locator_arm[0],locator_shoulder[0])
        
        
        
        
        ##--------------------------------------  mirror  locator ----------------------  
        #####                L_centerPoint_shoulder =  ['Rbs_L_shoulder_Temple',(4.313,141.467,-3.341)]
        #####                L_centerPoint_clavicle =  ['Rbs_L_clavicle_Temple',(0.977,141.822,0.417)]
        #####                L_centerPoint_arm =  ['Rbs_L_arm_Temple',(13.629,141.44,-4.259)]
        #####                L_centerPoint_foreArm =  ['Rbs_L_foreArm_Temple',(45.452,142.304,-3.516)]
        #####                L_centerPoint_hand =  ['Rbs_L_hand_Temple',(70.115,142.976,-2.121)]
        
        #===========================================================
        #-------------
        R_centerPoint_shoulder =  [ L_centerPoint_shoulder[0].replace('L_','R_') , (L_centerPoint_shoulder[1][0]*-1 ,L_centerPoint_shoulder[1][1] ,L_centerPoint_shoulder[1][2] )]
        R_centerPoint_clavicle =  [ L_centerPoint_clavicle[0].replace('L_','R_') , (L_centerPoint_clavicle[1][0]*-1 ,L_centerPoint_clavicle[1][1] ,L_centerPoint_clavicle[1][2] )]
        R_centerPoint_arm =  [ L_centerPoint_arm[0].replace('L_','R_') , (L_centerPoint_arm[1][0]*-1 ,L_centerPoint_arm[1][1] ,L_centerPoint_arm[1][2] )]
        R_centerPoint_foreArm =  [ L_centerPoint_foreArm[0].replace('L_','R_') , (L_centerPoint_foreArm[1][0]*-1 ,L_centerPoint_foreArm[1][1] ,L_centerPoint_foreArm[1][2] )]
        R_centerPoint_hand =  [ L_centerPoint_hand[0].replace('L_','R_') , (L_centerPoint_hand[1][0]*-1 ,L_centerPoint_hand[1][1] ,L_centerPoint_hand[1][2] )]

        
        R_locator_shoulder = [ locator_shoulder[0].replace('L_','R_') , (locator_shoulder[1][0]*-1 ,locator_shoulder[1][1] ,locator_shoulder[1][2] )]
        R_locator_arm = [ locator_arm[0].replace('L_','R_') , (locator_arm[1][0]*-1 ,locator_arm[1][1] ,locator_arm[1][2] )]
        
        self.LZ_createLocator_byInfo(locatorName = R_locator_arm[0], translateInfo = R_locator_arm[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname = R_locator_arm[0],Visscle = 3)
        #self.lockAttr( obj = R_locator_arm[0] ,attr =['sx','sy','sz','v'])
        mc.parent(R_centerPoint_arm[0],R_centerPoint_foreArm[0],R_centerPoint_hand[0],R_locator_arm[0])
        
        self.LZ_createLocator_byInfo(locatorName = R_locator_shoulder[0], translateInfo = R_locator_shoulder[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  R_locator_shoulder[0],Visscle = 3)
        #self.lockAttr( obj = R_locator_shoulder[0] ,attr =['sx','sy','sz','v'])
        mc.parent(R_centerPoint_shoulder[0],R_centerPoint_clavicle[0],R_locator_arm[0],R_locator_shoulder[0])
        
        ###````````````````````````````````````````````````````````````````````````````````
        
        mc.group(L_arm_curveTemple,locator_shoulder[0],n='L_arm_temple_grp')
        for sc in L_arm_curveTemple:
            self.referenceCurve(sc)
            skincluster_curve = self.getSkinCluster(sc)
            self.conneReverseAttr( skincluster_curve,1)
            
        mc.group(R_arm_curveTemple,R_locator_shoulder[0],n='R_arm_temple_grp')
        for sc in R_arm_curveTemple:
            self.referenceCurve(sc)
            skincluster_curve = self.getSkinCluster(sc)
            self.conneReverseAttr( skincluster_curve,1)
        
        
        '''
        =========================================================
        ||                                                     ||
        ||腿部 位置                                            ||
        ||the  location of leg                                 ||
        ||                                                     ||
        =========================================================
        '''
        L_centerPoint_upleg =  self.L_centerPoint_upleg
        L_centerPoint_leg =  self.L_centerPoint_leg
        L_centerPoint_foot =  self.L_centerPoint_foot
        L_centerPoint_toe =  self.L_centerPoint_toe
        L_centerPoint_toeend =  self.L_centerPoint_toeend
        
        L_centerPoint_inside =  self.L_centerPoint_inside
        L_centerPoint_outside =  self.L_centerPoint_outside
        
        L_centerPoint_toeDnEnd =  self.L_centerPoint_toeDnEnd
        L_centerPoint_reverseHeel =  self.L_centerPoint_reverseHeel
        
        #===========================================================
        #-------------
        locator_leg = self.locator_leg
        locator_foot = self.locator_foot
        
        L_leg_temple_curve_grp = []
        R_leg_temple_curve_grp = []
        
        L_leg_temple_allInfo = [L_centerPoint_upleg,L_centerPoint_leg,L_centerPoint_foot,L_centerPoint_toe,L_centerPoint_toeend,L_centerPoint_inside,L_centerPoint_outside,L_centerPoint_toeDnEnd ,L_centerPoint_reverseHeel]
        for lg_t_ai in L_leg_temple_allInfo:
            
            
            self.LZ_createJnt_byInfo( lg_t_ai[0], lg_t_ai[1],(0,0,0))
            reverseJnt = self.createReverseJnt(objname = lg_t_ai[0] ,stept =  1 )
            
            if mc.objExists(spine_reverse_temple_grp) == 0:
                mc.group(em=True,n = spine_reverse_temple_grp )
                
            else:
                pass
            mc.parent(reverseJnt , spine_reverse_temple_grp)
            
            
            #=======================================================
            #---------  mirror -----------------------
            R_legName = lg_t_ai[0].replace('L_','R_')
            R_leg_translate = (lg_t_ai[1][0]*-1,lg_t_ai[1][1],lg_t_ai[1][2] )
            
            self.LZ_createJnt_byInfo( R_legName, R_leg_translate ,(0,0,0))
            
            
            reverseJnt = self.createReverseJnt(objname = R_legName ,stept =  1 )
            
            if mc.objExists(spine_reverse_temple_grp) == 0:
                mc.group(em=True,n = spine_reverse_temple_grp )
                
            else:
                pass
            mc.parent(reverseJnt , spine_reverse_temple_grp)
            #----------------------------------------------------------
        L_leg_curvePointObj = [(L_centerPoint_upleg,L_centerPoint_leg,'L_upleg_Temple_curve'),(L_centerPoint_leg,L_centerPoint_foot,'L_leg_Temple_curve'),(L_centerPoint_foot,L_centerPoint_toe,'L_foot_Temple_curve'),(L_centerPoint_toe ,L_centerPoint_toeend,'L_footend_Temple_curve')]
        for lg_cpo in L_leg_curvePointObj:
            
            self.createStraightLine(curvename =lg_cpo[2] , LocationInfo = [lg_cpo[0][1],lg_cpo[1][1]])
            L_leg_temple_curve_grp.append( lg_cpo[2] )
            mc.skinCluster( lg_cpo[0][0],lg_cpo[1][0],lg_cpo[2])
            #======================================================
            #---------  mirror -----------------------
            
            R_startPositin = (lg_cpo[0][1][0]*-1,lg_cpo[0][1][1],lg_cpo[0][1][2])
            R_endPositin = (lg_cpo[1][1][0]*-1,lg_cpo[1][1][1],lg_cpo[1][1][2])
            
            R_startObj =  str(lg_cpo[0][0]).replace( 'L_', 'R_')
            R_endObj =  str(lg_cpo[1][0]).replace( 'L_', 'R_')
            
            R_arm_curveName = str(lg_cpo[2]).replace('L_','R_')
            
            self.createStraightLine(curvename =R_arm_curveName , LocationInfo = [R_startPositin,R_endPositin ])
            R_leg_temple_curve_grp.append( R_arm_curveName )
            
            mc.skinCluster( R_startObj , R_endObj ,R_arm_curveName )
            #-------------------------------------------------------------
            
        #===========================================================
        ##---------------------  parent locator -------------------
        
        self.LZ_createLocator_byInfo(locatorName = locator_foot[0], translateInfo = locator_foot[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  locator_foot[0],Visscle = 3)
        #self.lockAttr( obj = locator_foot[0] ,attr =['sx','sy','sz','v'])
        mc.parent(L_centerPoint_toe[0],L_centerPoint_toeend[0],L_centerPoint_foot[0],L_centerPoint_inside[0],L_centerPoint_outside[0],L_centerPoint_toeDnEnd[0] ,L_centerPoint_reverseHeel[0],locator_foot[0])
        
        self.LZ_createLocator_byInfo(locatorName = locator_leg[0], translateInfo = locator_leg[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  locator_leg[0],Visscle = 3)
        #self.lockAttr( obj = locator_leg[0] ,attr =['sx','sy','sz','v'])
        
        mc.parent(L_centerPoint_upleg[0],L_centerPoint_leg[0],locator_foot[0],locator_leg[0])
        
        
        
        ##--------------------------------------  mirror  locator ----------------------        


        R_centerPoint_upleg = [ L_centerPoint_upleg[0].replace('L_','R_') , (L_centerPoint_upleg[1][0]*-1 ,L_centerPoint_upleg[1][1] ,L_centerPoint_upleg[1][2] )]
        R_centerPoint_leg = [ L_centerPoint_leg[0].replace('L_','R_') , (L_centerPoint_leg[1][0]*-1 ,L_centerPoint_leg[1][1] ,L_centerPoint_leg[1][2] )]
        R_centerPoint_foot = [ L_centerPoint_foot[0].replace('L_','R_') , (L_centerPoint_foot[1][0]*-1 ,L_centerPoint_foot[1][1] ,L_centerPoint_foot[1][2] )]
        R_centerPoint_toe = [ L_centerPoint_toe[0].replace('L_','R_') , (L_centerPoint_toe[1][0]*-1 ,L_centerPoint_toe[1][1] ,L_centerPoint_toe[1][2] )]
        R_centerPoint_toeend = [ L_centerPoint_toeend[0].replace('L_','R_') , (L_centerPoint_toeend[1][0]*-1 ,L_centerPoint_toeend[1][1] ,L_centerPoint_toeend[1][2] )]
        
        R_centerPoint_inside = [ L_centerPoint_inside[0].replace('L_','R_') , (L_centerPoint_inside[1][0]*-1 ,L_centerPoint_inside[1][1] ,L_centerPoint_inside[1][2] )]
        R_centerPoint_outside = [ L_centerPoint_outside[0].replace('L_','R_') , (L_centerPoint_outside[1][0]*-1 ,L_centerPoint_outside[1][1] ,L_centerPoint_outside[1][2] )]
        R_centerPoint_toeDnEnd = [ L_centerPoint_toeDnEnd[0].replace('L_','R_') , (L_centerPoint_toeDnEnd[1][0]*-1 ,L_centerPoint_toeDnEnd[1][1] ,L_centerPoint_toeDnEnd[1][2] )]
        R_centerPoint_reverseHeel = [ L_centerPoint_reverseHeel[0].replace('L_','R_') , (L_centerPoint_reverseHeel[1][0]*-1 ,L_centerPoint_reverseHeel[1][1] ,L_centerPoint_reverseHeel[1][2] )]
        

        
        
        R_locator_leg = [ locator_leg[0].replace('L_','R_') , (locator_leg[1][0]*-1 ,locator_leg[1][1] ,locator_leg[1][2] )]
        R_locator_foot = [ locator_foot[0].replace('L_','R_') , (locator_foot[1][0]*-1 ,locator_foot[1][1] ,locator_foot[1][2] )]
        
        self.LZ_createLocator_byInfo(locatorName = R_locator_foot[0], translateInfo = R_locator_foot[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  R_locator_foot[0],Visscle = 3)
        #self.lockAttr( obj = R_locator_foot[0] ,attr =['sx','sy','sz','v'])
        mc.parent(R_centerPoint_toe[0],R_centerPoint_toeend[0],R_centerPoint_foot[0],R_centerPoint_inside[0],R_centerPoint_outside[0],R_centerPoint_toeDnEnd[0],R_centerPoint_toeDnEnd[0],R_centerPoint_reverseHeel[0],R_locator_foot[0])
        
        self.LZ_createLocator_byInfo(locatorName = R_locator_leg[0], translateInfo = R_locator_leg[1],rotateInfo = (0,0,0))
        self.locator_Vis_scale( locatorname =  R_locator_leg[0],Visscle = 3)
        #self.lockAttr( obj = R_locator_shoulder[0] ,attr =['sx','sy','sz','v'])
        
        mc.parent(R_centerPoint_upleg[0],R_centerPoint_leg[0],R_locator_foot[0],R_locator_leg[0])
        
        ###```````````````````````````````````````````````````````````````````````````
        
        mc.group(L_leg_temple_curve_grp,locator_leg[0],n='L_leg_temple_grp')
        for sc in L_leg_temple_curve_grp:
            self.referenceCurve(sc)
            skincluster_curve = self.getSkinCluster(sc)
            self.conneReverseAttr( skincluster_curve,1)
            
        mc.group(R_leg_temple_curve_grp,R_locator_leg[0],n='R_leg_temple_grp')
        for sc in R_leg_temple_curve_grp:
            self.referenceCurve(sc)
            skincluster_curve = self.getSkinCluster(sc)
            self.conneReverseAttr( skincluster_curve , 1)
            
            
        ####=========================================================
        #||
        #||
        #||
        ####=========================================================
        templectrl ='body_temple_control'
        self.creatControls_command(type = 5 ,curName= templectrl ,add=False)
        self.scaleCurveHull( templectrl ,50,50,50)
        self.lockAttr( obj = templectrl ,attr =['tx','rz','ry','v'])
        mc.parent(  'L_leg_temple_grp','R_leg_temple_grp', 'L_arm_temple_grp','R_arm_temple_grp', 'spine_temple_grp',spine_reverse_temple_grp,templectrl )
        
        
        
    """
        #=====================================================#
        #         Script Name: mirror locator temple   #
        #         Author:   lizhi                             #
        #         start date: Oct 31, 2014                    #
        #         start Updated: Oct 31, 2014                 #
        #         Update/Change this file at:                 #
        #         company: http://www.originalforce.com/      #
        #         Email:294596787@qq.com                      #
        # Please do not alter any information above this line #
        #=====================================================#
        #
        #python                                               #
        #directions (for use):                                #
        #                                                     #
        #                                                     #
        #=====================================================#
        """  
        
    def mirrorTempleLocator (self,direction = 'L'):
    
        templectrl ='body_temple_control'
        if mc.objExists(templectrl) == 0:
            pass
        else:
            allChilddren = mc.listRelatives(templectrl,ad =True)
            
            alljnt = mc.ls(allChilddren,type='joint')
            allLocatorsShape = mc.ls(allChilddren,type='locator')
            allLocator = []
            
            for als in allLocatorsShape:
                locator = mc.listRelatives(als,p=True)[0]
                allLocator.append(locator)
            
            locationTempleJnt = []
            for aj in alljnt:
                if '_reverse' not in aj:
                    locationTempleJnt.append(aj)

        for ltj in ( allLocator ):
        
            
                if direction == 'L':
                    if 'L_' in ltj:
                        location = mc.xform(ltj,q=True,t=True,ws=True)
                        location_ro = mc.xform(ltj,q=True,ro=True,ws=True)
                        
                        MirrorObj = str(ltj).replace('L_','R_')
                        
                        mc.xform( MirrorObj ,t=(location[0]*-1,location[1],location[2]),ws=True)
                        mc.xform( MirrorObj ,ro=(location_ro[0],location_ro[1]+ 180,location_ro[2]+180),ws=True)
                        
                if direction == 'R':
                    if 'R_' in ltj:
                        location = mc.xform(ltj,q=True,t=True,ws=True)
                        location_ro = mc.xform(ltj,q=True,ro=True,ws=True)
                        
                        MirrorObj = str(ltj).replace('R_','L_')
                        
                        mc.xform( MirrorObj ,t=(location[0]*-1,location[1],location[2]),ws=True)
                        
                        mc.xform( MirrorObj ,ro=(location_ro[0],location_ro[1]+ 180,location_ro[2]+180),ws=True)
                        
        for ltj in (  locationTempleJnt ):
        
            
                if direction == 'L':
                    if 'L_' in ltj:
                        location = mc.xform(ltj,q=True,t=True,ws=True)
                        location_ro = mc.xform(ltj,q=True,ro=True,ws=True)
                        
                        MirrorObj = str(ltj).replace('L_','R_')
                        
                        mc.xform( MirrorObj ,t=(location[0]*-1,location[1],location[2]),ws=True)
                        mc.xform( MirrorObj ,ro=(location_ro[0],location_ro[1]+ 180,location_ro[2]+180),ws=True)
                        
                if direction == 'R':
                    if 'R_' in ltj:
                        location = mc.xform(ltj,q=True,t=True,ws=True)
                        location_ro = mc.xform(ltj,q=True,ro=True,ws=True)
                        
                        MirrorObj = str(ltj).replace('R_','L_')
                        
                        mc.xform( MirrorObj ,t=(location[0]*-1,location[1],location[2]),ws=True)
                        mc.xform( MirrorObj ,ro=(location_ro[0],location_ro[1]+ 180,location_ro[2]+180),ws=True)
                        
            
        